﻿

namespace ManagerClinic.Ultilities.Ultility
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.Windows.Forms;
    public static class FunctionList
    {
        #region CONST
        public  const Int32 STS_SUCCESS = 1;
        public  const Int32 STS_NOT_AVAILABLE = -2;
        public  const Int32 STS_NOT_SUCCESS = 0;
        public  const Int32 STS_NULL = -1;
        public  const Int32 STS_AVAILABLE = 2;
        #endregion
        //strTitel: Tieu de hien thi .
        public static string FctOpenFileImage(string strTitel)
        {
            OpenFileDialog objOFile = new OpenFileDialog();
            objOFile.Title = strTitel;
            objOFile.Filter = "JPEG (*.JPG,*.JPEG,*.JPE,*.JFIF)|*.J*| GIF (*.GIF)|*.GIF| PNG (*.PNG)|*.PNG";
            if (objOFile.ShowDialog() == DialogResult.OK)
                return objOFile.FileName;
            else
                return null;
        }

        // Function copy file
        // PathSys: Noi copy file den
        // PathFile: File can copy
        // FileName: Ten file moi 
        public static int FctCopyFile(string PathSys, string PathFile, string FileName)
        {
            try
            {
                if (PathFile.Trim().Length > 0)
                {
                    FileInfo objFile = new FileInfo(PathFile);
                    string strPath = PathSys + FileName;
                    if (objFile.Exists)
                    {
                        strPath = strPath + objFile.Extension;
                        objFile.CopyTo(strPath, true);
                        return STS_SUCCESS; // Success
                    }
                    else
                        return STS_NOT_AVAILABLE; // file does not exist
                }
                return STS_NULL; // PathFile is null
            }
            catch (Exception ex) { LogExceptionUltilities.LogException("FctCopyFile", ex.Message); throw ex; }
           
        }
    }
}
